/**
4 * index页面的业务js
 */

// 全局变量
var bck01;// 当前页面选中的部门ID
var xinkairenId;
var cbm01;
var valueArr = {};// 参数
var ruyuanbingrenVaoList;
var zhenduanyijuHtml;//诊断依据
var zhenduanyieguoHtml;//诊断结果
var zhenduanindex=1;//诊断内容ID递增序数
var shouyeActiveId;
var timeId;//记录单击事件延迟时间
var bce03;
var bck01s="";
var isShuaka = false;
var pinquiry = false;
//新开页面打印的内容
var jibingList=[];//自费疾病列表
var yibaoJibingList=[];//医保疾病列表
var dataObjT = {};
var hccode;//医院编码
var vac01_;
var zhenjinVajList=[];
var beginTime;
var endTime;
var zhenjinList=[];//接诊时诊金列表
var fenzhen=1;
// 界面初始化完成后加载的脚本
$(document).ready(function() {
	yiyuanId = $("#yiyuanId").val();
	bck01=$("#bck01").val();
	var lvac01=$("#vac01").val();
	$.ajax({url:rootUrl+"/clidoctor/getBce03",type:"get",dataType:"json",data:{"bce01":bce01},async:false,success:function(data){bce03 = data.map.bce03}});
	/*$.ajax({url:rootUrl+"/clidoctor/getHccode",type:"get",dataType:"json",data:{"yiyuanId":yiyuanId},async:false,success:function(data){hccode = data.map.hccode}});*/
	getAllParams();
	newOrder();
	loadSelectAllList();//加载诊断信息下拉列表数据
	autoExpand();
	initSelectChekbox();//页面初始化select \checkbox
	patientDoctorAdvice(lvac01, 1);// 1
	
});
//页面中根据参数设置的功能
function setPageByParams(){
	//初始化solr索引库
	if (valueArr.p_100_105002_407=='1')
	{
		initSolrIndex();
	}
	//医嘱附加信息的默认展开或者隐藏
	var temp = valueArr["p_100_105002_394"];
	if(temp == "1"){
		$(".patient_operation").removeClass("expand");
	}else if(temp == "2"){
		$(".patient_operation").addClass("expand");
	}
	yizhuOtherInfo(); //医嘱附件信息展开还是收缩
}


//页面初始化select \checkbox
function initSelectChekbox(){
	$("#bdaSearch").select2({language: "zh-CN"});
	$("#advice_disort").select2({language: "zh-CN"})
	$('input').iCheck({
	    checkboxClass: 'icheckbox_square-blue',
	    radioClass: 'iradio_square-blue',
	    increaseArea: '20%' // optional
	});
}
/**
 * 初始化solr的索引库
 */
function initSolrIndex()
{
	debugger;
	if(valueArr.p_100_105002_407=='1'){
//		$.get(rootUrl+"/solr/initAdviceIndex",{params:JSON.stringify({"yiyuanId":yiyuanId,"bck01":bck01})},function(){});
//		$.ajax({url:rootUrl+"/solr/initzhenduanIndex",data:{params:JSON.stringify({corporationid:yiyuanId})},dataType:'json',type:'get', success:function(data){}});
//		//加载新开页面的医保疾病列表
//		$.ajax({url:rootUrl+"/solr/inityibaozhenduanIndex",data:{params:JSON.stringify({corporationid:yiyuanId})},dataType:'json',type:'get', success:function(data){}});
	}
}

/**
 * 加载诊断信息下拉数据
 */
function loadSelectAllList()
{
	//诊断依据
	var url2 = rootUrl + "/cliparamter/yijuList";
	var params2 = {};
	$.get(url2, params2, function(data2) {
		
		var list2 = data2.list;
		zhenduanyijuHtml = "<select>";
		zhenduanyijuHtml += "<option value='-1'>-请选择-</option>";
		for (var i = 0; i < list2.length; i++) {
			var option ="<option value="+list2[i]["bgp01"]+">"+list2[i]["bgp02"]+"</option>";
			zhenduanyijuHtml += option;
		}
		zhenduanyijuHtml+="</select>";
		//诊断结果
		var url3 = rootUrl + "/cliparamter/zhenduanjieguoList";
		var params3 = {};
		$.get(url3, params3, function(data3) {
			var list3 = data3.list;
			zhenduanyieguoHtml ="<select>";
			zhenduanyieguoHtml += "<option value='-1'>-请选择-</option>";
			for (var j = 0; j < list3.length; j++) {
				var option ="<option value="+list3[j]["ady01"]+">"+list3[j]["ady02"]+"</option>";
				zhenduanyieguoHtml += option;
			}
			zhenduanyieguoHtml+="</select>";
			shouyeEvent();//首页
		});
	});
	
}

// 获取界面参数设置
function getAllParams() {
	debugger;
	$.ajax({
		url : rootUrl + "/patientsearch/findSysparams",
		data : {userid:userId,bck01:bck01},
		async : false,
		success : function(data) {
			var list = data.list;
			for (var i = 0; i < list.length; i++) {
				valueArr[list[i]["para_key"]] = list[i]["value"];
			}
			setPageByParams();
			
		}
	});
	//加载新开页面的自费疾病树形结构数据
	$.ajax({url:rootUrl+"/treatment/jibingList",data:{params:JSON.stringify({yiyuanId:yiyuanId})},dataType:'json',type:'get', success:function(data){if(data)
	{
		jibingList = data.list;
	}}});
	//加载新开页面的医保疾病列表
	$.ajax({url:rootUrl+"/treatment/yibaoJibingList",data:{params:JSON.stringify({corporationid:yiyuanId})},dataType:'json',type:'get', success:function(data){if(data)
	{
		yibaoJibingList = data.list;
	}}});
}

// 医嘱单全选事件
function choseAllEvent() {
	var all = $("#advice_table table thead").find("input[type='checkbox']");
	var sub = $("#advice_table table tbody").find(".innerHead").find("input[type='checkbox']");
	$(all).on('ifChecked', function(event){
		$(sub).iCheck('check');
	});
	$(all).on('ifUnchecked', function(event){
		$(sub).iCheck('uncheck');
	});
}
function yizhuOtherInfo(that){
	debugger;
	var flag = $("#patient_operation").hasClass("expand");
	if(flag){
		$('.yizhu_content_table').animate({'height':"92%"},"fast");
		$(".patient_operation").removeClass("expand");
		$(".patient_operation").find('.more-info-text').text('展开');
		$(".yizhujilu_content").hide();
		$(".patient_operation").find('.caret').addClass('caret-top');
		
	}else{
		$('.yizhu_content_table').animate({'height':"55%"},"fast");
		$(".patient_operation").find('.more-info-text').text('收缩');
		$(".patient_operation").addClass("expand");
		$(".yizhujilu_content").show();
		$(".patient_operation").find('.caret').removeClass('caret-top');
	}
}

function autoExpand(){
	$(".patient_operation li").on("click",function(){
	if(!$(this).hasClass("moreCont")){
		var tab = $(this).parents(".tab-pane");
		if(($(this).parents(".patient_operation ").find(".yizhujilu_content").is(":hidden"))){
			tab.find('.yizhu_content_table').animate({'height':"55%"},"fast");
			tab.find(".patient_operation").find('.more-info-text').text('收缩');
			tab.find(".patient_operation").addClass("expand");
			tab.find(".yizhujilu_content").show();
			tab.find(".patient_operation").find('.caret').removeClass('caret-top');
		}
	}
	})
}
// table折叠
function zhedie() {
	$(".innerHead").find("button").on("click",function() {
				var e=arguments.callee.caller.arguments[0]||event; 
				if (e && e.stopPropagation) { 
					// this code is for Mozilla and Opera
					e.stopPropagation(); 
				} else if (window.event) { 
					// this code is for IE 
					window.event.cancelBubble = true; 
				} 
				if ($(this).parents("tr").siblings().css("display") == "none") {
					$(this).parents("tr").find("lable").removeClass(
							"glyphicon glyphicon-chevron-up")
					$(this).parents("tr").find("lable").addClass(
							"glyphicon glyphicon-chevron-down");
					$(this).parents("tr").siblings().removeClass("hidden");
				} else {
					$(this).parents("tr").find("lable").removeClass(
							"glyphicon glyphicon-chevron-down");
					$(this).parents("tr").find("lable").addClass(
							"glyphicon glyphicon-chevron-up");
					$(this).parents("tr").siblings().addClass("hidden");
				}
				$(this).parents("tr").find("input[type='checkbox']").iCheck('uncheck');
			})
}

function sendJiezhen(row)
{
	debugger;
	$.ajax({
		url: mqUrl+'/Mq/MQ/eliminateTopic' ,
		type:"GET",
		async: false,
		data: {
			topicName : msgName,
			userId : bce01,
			messageType : JSON.stringify({bce01s:"(1,2)",row:row,type:"sendJiezhen"})
		},
		dataType:"jsonp",
		success:function(json){
		}
	});
}


// 根据bck01加载医师列表
function loadBce1() {
	var bck01 = $("#zhuanrukeshi").find("option:selected").val();
	var url = rootUrl + "/treatment/loadBce1";
	var params = {};
	params.bck01 = bck01;
	$("#jiezhenyishi").empty();
	$.get(url, params, function(data) {
		var list = data.list;
		var option = $("<option>").attr('value', 0).text("请选择");
		$("#jiezhenyishi").append(option);
		for (var i = 0; i < list.length; i++) {
			var option = $("<option>").attr('value', list[i]['bce01']).text(
					list[i]['bce03']);
			$("#jiezhenyishi").append(option);
		}
	});
}
// 医嘱单tr选中事件
function adviceChoseTr() {
	$("#advice_table").find(".yizhu_details").on(
			"click",
			function() {
				$(this).addClass("choseedTr").siblings().removeClass("choseedTr");
				$(this).parents("tbody").siblings().find("tr").removeClass("choseedTr");
			});
}
// 病人医嘱记录
function patientDoctorAdvice(lvac01, curr) {
	var that = this;
	// that.frist = true;
	$.ajax({
		url : rootUrl + "/doctoradvice/getpatientsdoctoradvice",
		type : "post",
		async : false,
		data : {
			"lVAF06" : lvac01,
			"lVAF04" : 1,
			"lBCE01A" : bce01,
//			currPage : curr,
//			pageSize : pageSize,
			VAF74 : "",
			VAF36 : ""
		},
		dataType : 'json',
		success : function(data) {
			that.laytplUrl_T(myurl + "/module/advice_table.html", data,
					function(data, html) {
						$("#advice_table").html(html);
						choseAllEvent();// 全选事件
						otherProperties();
						checkboxEvent1();
						checkboxEvent4();
						checkboxEvent8();
						advicetongzu();// 同组记录
						adviceChoseTr();// 医嘱tr选中事件
						backAdviceStyle();//医嘱作废样式
						zhedie();
						$("#advice_table").find('input').iCheck({
						    checkboxClass: 'icheckbox_square-blue',
						    radioClass: 'iradio_square-blue',
						    increaseArea: '20%' // optional
						  });
					});
		}
	});
}
//作废样式
function backAdviceStyle(){
	$(".yizhu_details").each(function(index, ele) {
		var fstatus=JSON.parse($(ele).attr("data-info")).fstatus;
		if(fstatus=="医嘱退费"){
			$(this).addClass("backAdvice");
		}
	})
}
// 医嘱单同组
function advicetongzu() {
	var tzTdindex = [ 3, 6 ];
	$("#advice_table tbody").each(function(index, ele) {
						var vaf59Arr = [];
						var adviceList = $(ele).find(".yizhu_details");
						for (var k = 0; k < adviceList.length; k++) {
							var dataobj = JSON.parse($(adviceList[k]).attr("data-info"));
							vaf59Arr.push(dataobj.vaf59);
						}
						vaf59Arr = vaf59Arr.unique2();
						var resultArr = [];
						for (var i = 0; i < vaf59Arr.length; i++) {
							var tongzuEditArr = [];
							for (var j = 0; j < adviceList.length; j++) {
								if (JSON.parse($(adviceList[j]).attr("data-info")).vaf59 == vaf59Arr[i]) {
									tongzuEditArr.push($(adviceList[j]).index());
								}
							}
							if (tongzuEditArr.length > 1) {

								for (var m = 0; m < tzTdindex.length; m++) {// 要同组的tr
																			// 的下标
									for (var n = 0; n < tongzuEditArr.length; n++) { // 同组的td
																						// 的下标[3,6]
										if (n == 0) { // 同组tr为第一行的，只把td的bottom
														// 去掉
											$($(ele).find("tr")[tongzuEditArr[n]]).find("td:eq("+ tzTdindex[m]+ ")").addClass("xiyaoTzCss");
										} else if (n == (tongzuEditArr.length - 1)) {// 如果为最后一行，只把text隐藏
											$($(ele).find("tr")[tongzuEditArr[n]]).find("td:eq("+ tzTdindex[m]+ ")").text("");
										} else {// 如果为中间的tr，则隐藏text,并bottom 去掉
											$($(ele).find("tr")[tongzuEditArr[n]]).find("td:eq("+ tzTdindex[m]+ ")").text("");
											$($(ele).find("tr")[tongzuEditArr[n]]).find("td:eq("+ tzTdindex[m]+ ")").addClass("xiyaoTzCss");
										}
									}
								}
							}
						}

					})
}


//检查报告
function jianchabaogao() {
	debugger;
	var that = this;
//	var url = rootUrl + "/patientcase/doctorviewimageresult";
	var url = "http://192.168.3.154:8085/onehismq/Mq/MQRisPacs/selectRicPacs";
	var params = {};
	params.ACF01 = 3;
//	params.VAA01 = $("#vaa01").val();//
	params.VAA01 = 1918;//
//	params.VAA07 = $("#vac01").val();
	params.VAA07 = 1883;
	params.currPage = 1;
	params.pageSize = 20;
	$.ajax({url:url, data:params, type:"get",dataType:"jsonp",success:function(data) {
		debugger;
		jianChaJqGride(data);
//		var list = data;
//		$("#jc_sj").val(JSON.stringify(list));// 存储数据
//		if (list) {
//			that.laytplUrl(myurl + "/module/Inspection_report.html",
//					list, function(list, html) {
//						$("#jiancha_baogao").html(html);
//
//					});
//		}
	},
	error:function(a,b,c)
	{
		console.log(c);
	}
	
	});
}
//检查根据分组规则重组table
function jcRecombination() {
	if(($("#jc_sj").val())&&($("#jc_sj").val()!="[]")){
	var dataObj = JSON.parse($("#jc_sj").val());
	var fenzu1 = $("#jiancha_fenzu1").val();
	var fenzu2 = $("#jiancha_fenzu2").val();
	var fenzu3 = $("#jiancha_fenzu3").val();
	dataObj=$.extend(dataObj,{"fenzu1":fenzu1},{"fenzu2":fenzu2},{"fenzu3":fenzu3},{"type":"jc_baogao"});
	diguiEvent(dataObj);
	}else{
		$("#jiancha_baogao").empty().html("暂无数据");
//		layer.msg("暂无数据！" ,{time:2000,icon:0});
	}
}
//检查分组后模板绑定
function jianchaShowResult(firstArr,fenzuobj){
	var fenzu1=fenzuobj.fenzu1;
	var fenzu2=fenzuobj.fenzu2;
	var fenzu3=fenzuobj.fenzu3;
	if((fenzu1!=-1)&&(fenzu2!=-1)&&(fenzu3!=-1)){//三个分组
		
		laytplUrl(myurl + "/module/Inspection_report1.html",firstArr, function(data, html) {
			$("#jiancha_baogao").empty().html(html);
			$("#jiancha_1_table").treetable({ expandable: true,initialState : 'expanded' });
		});
	}else if((fenzu1!=-1)&&(fenzu2!=-1)){//两层分组
		
		laytplUrl(myurl + "/module/Inspection_report2.html",firstArr, function(data, html) {
			$("#jiancha_baogao").empty().html(html);
			$("#jiancha_2_table").treetable({ expandable: true,initialState : 'expanded' });
		});
	}else if(fenzu1!=-1){//一层分组
		
		laytplUrl(myurl + "/module/Inspection_report3.html",firstArr, function(data, html) {
			$("#jiancha_baogao").empty().html(html);
			$("#jiancha_3_table").treetable({ expandable: true,initialState : 'expanded' });
		});
	}else{//不分组
		laytplUrl(myurl + "/module/Inspection_report.html",firstArr, function(data, html) {
			$("#jiancha_baogao").empty().html(html);
			$("#jiancha_table").treetable({ expandable: true,initialState : 'expanded' });
		});
	}
}

//排序
function bubbleSort(arr) {
    var i = arr.length, j;
    var tempExchangVal;
    while (i > 0) {
        for (j = 0; j < i - 1; j++) {
            if (arr[j] <arr[j + 1]) {
                tempExchangVal = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = tempExchangVal;
            }
        }
        i--;
    }
    return arr;
}

// 新开页面：
function newOrder() {
	var that = this;
	$("#newpage").on("click",function() {
		$("#newpage").attr("disabled",true);
		debugger;
		var table_id;
		var cur_tab = $("#all_patient").find(".active a").attr("href");
		if(cur_tab == "#mypatinent1"){
			table_id = "myjiezhenTableList";
			
		}else if(cur_tab == "#benkepatient1"){
			table_id = "jiezhenBenkeTable";
		}
		var selectedId = $("#"+table_id).jqGrid("getGridParam", "selrow")
		var selectRow =$("#"+table_id).jqGrid("getRowData", selectedId);
		var isoperate = isOperateAdvice();
		if(!isoperate){
			layer.msg("该病人已经过了开嘱期限，请重新挂号！",{ time: 3000,icon: 0,skin: 'layui-layer-msg0'});
			return false;
		}
		$("#newpage").attr("disabled",true);

				var vaa01 ="863234045625114624";
				var vac01_n ="961409482796044289";
				var vaa01 = $("#vaa01").val();
				var vac01_n = $("#vac01").val();
				if (vac01_n) {
					var vaa05 = $("#vaa05").val();
					var indexN = layer.open({
//						id:"neworder_iframe",
						type : 2,
						title : '新开医嘱--'+vaa05,
						area : [ "95%", "95%" ],
						shade : 0.3,
						maxmin : true,
						id:"neworder_layer",
						content :hosturl+"/outto/neworder_out.jsp?vaa01="+vaa01+"&vac01="+vac01_n+"&bck01="+$("#bck01").val()+"&vaa05="+vaa05+"&yiyuanId="+yiyuanId,
						cancel: function(indexN){ 
							$(".layui-layer-close").blur();//让关闭按钮失去焦点，避免回车重复触发
							//跨域保存病历
							orderInIndex();
							return false;
							},
						success:function(layero){
							$("#newpage").removeAttr("disabled");
						},		
						min: function (layero) {
			                var times = layero.attr('times');
			                $('#layui-layer-shade' + times).hide();
			            },
			            restore: function (layero) {
			                var times = layero.attr('times');
			                if ($('#layui-layer-shade' + times).css('display') == 'none') {
			                    $('#layui-layer-shade' + times).show();
			                }
			            },

					});
				} else {
					layer.msg("请选择就诊病人", {
						time : 2000,
						icon : 0,
						skin: 'layui-layer-msg0'
					});
				}
				$("#newpage").removeAttr("disabled");
			});
}

// 根据医嘱类型查询医嘱记录
function changeAdcive() {
	var searchStr = $("#bdaSearch>option:selected").attr("id");
	if (searchStr != "") {
		$("#advice_table tbody").hide().filter(":contains('" + searchStr + "')").show();
	} else {
		$("#advice_table tbody").show();
	}
}

// 根据医嘱状态查询医嘱（前端实现）
function checkboxEvent1()
{
	$('#vaf10_1').on('ifChecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('新开')").parents("tbody").show();
	});
	$('#vaf10_1').on('ifUnchecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('新开')").parents("tbody").hide();
	});

}
// 发送
function checkboxEvent8()
{
	$('#vaf10_8').on('ifChecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('已发送')").parents("tbody").show();
	});
	$('#vaf10_8').on('ifUnchecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('已发送')").parents("tbody").hide();
	});

}

function checkboxEvent4()
{
	// 作废
	$('#vaf10_4').on('ifChecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('医嘱退费')").parents("tbody").show();
	});
	$('#vaf10_4').on('ifUnchecked', function(event)
	{
		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('医嘱退费')").parents("tbody").hide();
	});
}
// 医嘱记录更多操作
function moreOperation() {
	$(".patient_operation .moreCont").on("click", function() {
		if ($(".yizhujilu_content").css("display") == "none") {
			$("#table_list").addClass("hidden");
			$(".yizhujilu_content").removeClass("hidden");
			$(".patient_operation .moreCont").text("折叠");
		} else {
			$("#table_list").removeClass("hidden");
			$(".yizhujilu_content").addClass("hidden");
			$(".patient_operation .moreCont").text("展开");
		}

	})
}
 
function headPrice(cbm01)
{
	$.post(rootUrl+"/doctoradvice/doctoradvicedetail",{"lCBM01":cbm01},function(data)
	{
		vbd_jqgrid(data.list);
	});
}


// 医嘱单选定，并查看医嘱信息
function otherProperties()
{
	debugger;
	loadZhenjinEditTable();
	$(".innerHead").on("click",function()
	{
		if($(this).find("input:checked").length>0){
			$(this).find("input[type='checkbox']").iCheck('uncheck');
		}else{
			
			$(this).find("input[type='checkbox']").iCheck('check');
		}
		var cbm01 = $(this).attr("data-cbm01list");
		var data_info = $($(this).parents("tbody").find(".yizhu_details")[0]).attr("data-info");
		var vaf10 = JSON.parse(data_info).vaf10;
		
		var vaf01 = JSON.parse(data_info).vaf01;
		debugger;
		if(vaf10==1)
		{
			//1349
			$.post(rootUrl+"/doctoradvice/doctoradvicepriceinfo",{"lCBM01":cbm01,"ABC02":$("abc02").text()},function(data)
					{
						$("#vaf1Fasongjilu_table").empty();
						vbd_jqgrid(data.list);
					});
		}
		else if(vaf10==8)
		{
			//1402
			dataObjT={fun:'1',cbm01:cbm01};
			headPrice(cbm01);
			//1405 医嘱单发送记录
			$.post(rootUrl+"/doctoradvice/sendadvicehistory",{"lCBM01":cbm01},function(data)
					{
				var list = data.list;
				$("#vaf1Fasongjilu_table").empty();
	    		for(var i= 0;i<list.length;i++)
	    		{
	    			var td1 = $("<td>"+(list[i]["fvbi15"]?list[i]["fvbi15"]:'未结账')+"</td>");
	    			var td2 = $("<td>"+(list[i]["vbi09"]?list[i]["vbi09"]:'')+"</td>");
	    			var td3 = $("<td>"+(list[i]["nbby05"]?list[i]["nbby05"]:'')+"</td>");
	    			var td5 = $("<td>"+(list[i]["vbi07"]?list[i]["vbi07"]:'')+"</td>");
	    			var td6 = $("<td>"+(list[i]["bck03"]?list[i]["bck03"]:'')+"</td>");
	    			var td7 = $("<td>"+(list[i]["bce03a"]?list[i]["bce03a"]:'')+"</td>");
	    			var td8 = $("<td>"+(list[i]["fvbi13"]?list[i]["fvbi13"]:'')+"</td>");
	    			var td9 = $("<td>"+(list[i]["vai04"]?list[i]["vai04"]:'')+"</td>");
	    			var td10 = $("<td>"+(list[i]["vbi21"]?list[i]["vbi21"]:'')+"</td>");
	    			var tr = $("<tr></tr>");
	    			tr.append(td1);
	    			tr.append(td2);
	    			tr.append(td3);
//	    			tr.append(td5);
	    			tr.append(td6);
	    			tr.append(td7);
	    			tr.append(td8);
	    			tr.append(td9);
	    			tr.append(td10);
	    			$("#vaf1Fasongjilu_table").append(tr);
	    		}
					});
		}
		//7501 医嘱单处方属性
		var params = {};
		params.iaa01 = 0;
		params.acf01 = 1;
		
		params.vaf01 = vaf01;
	    	$.post(rootUrl+"/doctoradvice/doctoradviceprescriptionproperty",params,function(data){
	    		var list = data.list;
	    		$("#chufangshuxing_table tbody").empty();
	    		for(var i= 0;i<list.length;i++)
	    		{
	    			var td1 = $("<td>"+(list[i]["cbm07"]?list[i]["cbm07"]:'')+"</td>");
	    			var td2 = $("<td>"+(list[i]["bjw02"]?list[i]["bjw02"]:'')+"</td>");
	    			var td3 = $("<td>"+(list[i]["iai03"]?list[i]["iai03"]:'')+"</td>");
	    			var tr = $("<tr></tr>");
	    			tr.append(td1);
	    			tr.append(td2);
	    			tr.append(td3);
	    			$("#chufangshuxing_table tbody").append(tr);
	    		}
	    	});
		//1176 医嘱单处方诊断//暂时注释掉，新的在zhenduan.js
	    	adviceDiagnose(cbm01,'chufang_zhenduan');
	});
	$(".yizhu_details").on("click", function(e)
	{
		/*
		 * if(e.target.tagName=="INPUT"){ return; }
		 */
		$(this).addClass("choseedTr").parent().siblings().find(".yizhu_details").removeClass("choseedTr");
		
		var dataStr = $(this).attr("data-info");
		var dataObj = JSON.parse(dataStr);
		cbm01 = dataObj.cbm01;
		dataObjT={fun:'2',dataObj:dataObj};
		vbdInfo(dataObj);
		// 处方诊断
		adviceDiagnose(dataObj.cbm01,"chufang_zhenduan");
		// 处方性质
		chufangshuxing(dataObj.vaf01,"chufang_xingzhi");
		// 手术人员安排
		shouShuRenYuanAnpai(dataObj.vaf01);
		//1405 医嘱单发送记录
		sendAdviceHistory(dataObj.vaf01,dataObj.cbm01,"jizhu_fasong");
		// 加载打印医嘱列表

		// printAdvice(bda01);
	})

}
function sendAdviceHistory(vaf01,cbm01,tabid){
	debugger;
	var target = $("#"+tabid).find("tbody");
	$.post(rootUrl+"/doctoradvice/sendadvicehistory_vaf",{"vaf01":vaf01,"cbm01":cbm01},function(data)
			{
		
		var list = data.list;
		target.empty();
		for(var i= 0;i<list.length;i++)
		{
			var td1 = $("<td>"+(list[i]["fvbi15"]?list[i]["fvbi15"]:'未结账')+"</td>");
			var td2 = $("<td>"+(list[i]["vbi09"]?list[i]["vbi09"]:'')+"</td>");
			var td3 = $("<td>"+(list[i]["nbby05"]?list[i]["nbby05"]:'')+"</td>");
			var td5 = $("<td>"+(list[i]["vbi07"]?list[i]["vbi07"]:'')+"</td>");
			var td6 = $("<td>"+(list[i]["bck03"]?list[i]["bck03"]:'')+"</td>");
			var td7 = $("<td>"+(list[i]["bce03a"]?list[i]["bce03a"]:'')+"</td>");
			var td8 = $("<td>"+(list[i]["fvbi13"]?list[i]["fvbi13"]:'')+"</td>");
			var td9 = $("<td>"+(list[i]["vai04"]?list[i]["vai04"]:'')+"</td>");
			var td10 = $("<td>"+(list[i]["vbi21"]?list[i]["vbi21"]:'')+"</td>");
			var tr = $("<tr></tr>");
			tr.append(td1);
			tr.append(td2);
			tr.append(td3);
			/*tr.append(td5);*/
			tr.append(td6);
			tr.append(td7);
			tr.append(td8);
			tr.append(td9);
			tr.append(td10);
			target.append(tr);
		}
			});
}
// 打印选中医嘱单，添加打印类型
function printCheckedEvent(){
	$(".dropdown-menu select").select2();
	if ($(".innerHead td input:checked").length <= 0)
	{
		layer.msg("请勾选要打印的医嘱单",
		{
		time : 2000,
		icon : 0,
		skin: 'layui-layer-msg0'
		});
		return;
	}
	else if($(".innerHead td input:checked").length > 1)
	{
		layer.msg("只能勾选一个已发送的医嘱单",
				{
				time : 2000,
				icon : 0,
				skin: 'layui-layer-msg0'
				});
				return;
	}
	else
	{
			var dataStr=$($(".innerHead td input:checked").parents("tbody").find(".yizhu_details")[0]).attr("data-info");
			var dataObj = JSON.parse(dataStr);
			cbm01 = dataObj.cbm01;
			var bda01 = dataObj.bda01;
			var vaf10 = dataObj.vaf10;
			if(vaf10!=8)
			{
				layer.msg("请先发送医嘱单",
						{
						time : 2000,
						icon : 0,
	    				skin: 'layui-layer-msg0'
						});
						return;
			}
			printAdvice(bda01,vaf10,dataObj.cbm07);//vaf10 判断是否是医嘱单状态
		}
}

// 加载打印格式下拉列表
function printAdvice(bda01,vaf10,cbm07) {
	var rid;
	switch (bda01)
	{
		case "1" :
			rid = justXiyaoType(cbm07,rid);
			break;
		case "2" :
			rid = justXiyaoType(cbm07,rid);
			break;
		case "8" :
			rid = 25;
			break;
		case "E" :
			rid = 22;
			break;
		case "L" :
			rid = 23;
			break;
		case "S" :
			rid = 28;
			break;
		case "4" :
			rid = 999;//待定
			break;
		case "M" :
			rid = 999;//待定
			break;
		default ://治疗
			rid = 190;
			break;
	}
	var html ="";
	var myAjax = $.ajax({
		url : printUrl + "/printtemprest/findListByRid/" + rid+"?jsessionids="+$.cookie('jsessionids'),
		type : "get",
		async : true,
		dataType : "json",
		traditional : true,
		success : function(data) {
			var defaultV1;
			for (var i = 0; i < data.length; i++) {
				var obj = {};
				obj.vaf10 = vaf10;
				obj.id = data[i]['id'];
				if (data[i]['xdefault'] == "1") {
					defaultV1 = data[i].id;
					 html += '<option data-info='+JSON.stringify(obj)+' value='+data[i].id+'>'+data[i]['name']+'</option>';
				} else {
					 html += '<option data-info='+JSON.stringify(obj)+' value='+data[i].id+'>'+data[i]['name']+'</option>';
				}
			}
			$("#advice_print").empty().append(html);
			$("#advice_print").select2();
			if(defaultV1){
				
				$("#advice_print").val(defaultV1).trigger("change");
			}
			if (bda01=="1")
			{
				$(".iswest").show();
				var html1 = "";
				//输液卡
				$.ajax(
				{
				url : printUrl + "/printtemprest/findListByRid/" + 101 + "?jsessionids=" + $.cookie('jsessionids'),
				type : "get",
				async : false,
				dataType : "json",
				traditional : true,
				success : function(data)
				{
					var defaultV2;
					for (var i = 0; i < data.length; i++)
					{
						var obj = {};
						obj.vaf10 = vaf10;
						obj.id = data[i]['id'];
						if (data[i]['xdefault'] == "1")
						{
							defaultV2 = data[i].id;
							html1 += '<option data-info=' + JSON.stringify(obj) + ' value='+data[i].id+'>' + data[i]['name'] + '</option>';
						}
						else
						{
							html1 += '<option data-info=' + JSON.stringify(obj) + ' value='+data[i].id+'>' + data[i]['name'] + '</option>';
						}
					}
					$("#advice_print_shuye").empty().append(html1);
					$("#advice_print_shuye").select2();
					if(defaultV2){
						
						$("#advice_print_shuye").val(defaultV2).trigger("change");
					}
				}
				});
				//皮试单
				var html2="";
				$.ajax(
						{
							url : printUrl + "/printtemprest/findListByRid/" + 102 + "?jsessionids=" + $.cookie('jsessionids'),
							type : "get",
							async : false,
							dataType : "json",
							traditional : true,
							success : function(data)
							{
								var defaultV3;
								for (var i = 0; i < data.length; i++)
								{
									var obj = {};
									obj.vaf10 = vaf10;
									obj.id = data[i]['id'];
									if (data[i]['xdefault'] == "1")
									{
										defaultV3 = data[i].id;
										html2 += '<option data-info=' + JSON.stringify(obj) + '  value='+data[i].id+'>' + data[i]['name'] + '</option>';
									}
									else
									{
										html2 += '<option data-info=' + JSON.stringify(obj) + '  value='+data[i].id+'>' + data[i]['name'] + '</option>';
									}
								}
								$("#advice_print_pishi").empty().append(html2);
								$("#advice_print_pishi").select2();
								if(defaultV3){
									
									$("#advice_print_pishi").val(defaultV3).trigger("change");
								}
							}
						});
				
			}
			else
			{
				$("#advice_print_shuye").empty();
				$("#advice_print_pishi").empty();
				$(".iswest").hide();
			}
			
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.msg('打印服务器连接失败！', {
				time : 2000,
				icon : 3,
				skin: 'layui-layer-msg3'
			});
		}
	});

}
//选择打印格式
function chosePrintType(){
	 var e=arguments.callee.caller.arguments[0]||event; 
	 if (e && e.stopPropagation) { 
	  // this code is for Mozilla and Opera
	  e.stopPropagation(); 
	 } else if (window.event) { 
	  // this code is for IE 
	  window.event.cancelBubble = true; 
	 } 
}

// 医嘱打印预览
function print1() {
	debugger;
	var datastr = $("#advice_print option:selected").attr("data-info");
	if(datastr){
		var dataObj = JSON.parse(datastr);
		var id = dataObj.id;
		var vaf10 = dataObj.vaf10;
		if(vaf10 == '8'){
			var url = printUrl + "/printtoolrest/printToPdfView/" + id + "?cbm01="
			+ cbm01+"&jsessionids="+$.cookie('jsessionids');
			window.open(url);
		}else{
			if(vaf10 == '1'){
				layer.alert("请先发送医嘱单！");
			}else if(vaf10 == '4'){
				layer.alert("医嘱已作废，请重开！");
			}
		}
	}else{
		layer.msg("请选择打印的医嘱单！",{time:2000,icon:0,skin: 'layui-layer-msg0'});
	}
}
function print11() {
	var datastr = $("#advice_print_shuye option:selected").attr("data-info");
	if(datastr){
		var dataObj = JSON.parse(datastr);
		var id = dataObj.id;
		var vaf10 = dataObj.vaf10;
		if(vaf10 == '8'){
			var url = printUrl + "/printtoolrest/printToPdfView/" + id + "?cbm01="
			+ cbm01+"&jsessionids="+$.cookie('jsessionids');
			window.open(url);
		}else{
			if(vaf10 == '1'){
				layer.alert("请先发送医嘱单！");
			}else if(vaf10 == '4'){
				layer.alert("医嘱已作废，请重开！");
			}
		}
	}else{
		layer.msg("请选择打印的医嘱单！",{time:2000,icon:0,skin: 'layui-layer-msg0'});
	}
}
function print111() {
	var datastr = $("#advice_print_pishi option:selected").attr("data-info");
	if(datastr){
		var dataObj = JSON.parse(datastr);
		var id = dataObj.id;
		var vaf10 = dataObj.vaf10;
		if(vaf10 == '8'){
			var url = printUrl + "/printtoolrest/printToPdfView/" + id + "?cbm01="
			+ cbm01+"&jsessionids="+$.cookie('jsessionids');
			window.open(url);
		}else{
			if(vaf10 == '1'){
				layer.alert("请先发送医嘱单！");
			}else if(vaf10 == '4'){
				layer.alert("医嘱已作废，请重开！");
			}
		}
	}else{
		layer.msg("请选择打印的医嘱单！",{time:2000,icon:0,skin: 'layui-layer-msg0'});
	}
}


// 加载病人的处方诊断信息
function chufangzhenduan(vaf01) {
	var url = rootUrl + "/doctoradvice/doctordiagnosis";
	var params = {};
	params.lVAF01 = vaf01;
	params.acf01 = 1;
	$.post(url, params, function(data) {
		var list = data.list;
		$("#chufangzhenduan_table").empty();
		for (var i = 0; i < list.length; i++) {
			var tr = $("<tr></tr>");
			var td2 = $("<td></td>");
			var td22 = $("<td>" + (list[i]["vao15"]?list[i]["vao15"]:'') + "</td>");
			tr.append(td2);
			tr.append(td22);
			$("#chufangzhenduan_table").append(tr);
		}
//		tr.append(td1);
	})
}
    
    
    
    //加载病人处方属性
    function chufangshuxing(vaf01,tabid)
    {
    	var target = $("#"+tabid).find("tbody");
    	var url = rootUrl + "/doctoradvice/doctoradviceprescriptionproperty";;
    	var params= {};
    	params.iaa01 = 0;
    	params.acf01 = 1;
    	params.vaf01 = vaf01;
    	$.post(url,params,function(data){
    		var list = data.list;
    		
    		target.empty();
    		for(var i= 0;i<list.length;i++)
    		{
    			var td1 = $("<td>"+(list[i]["cbm07"]?list[i]["cbm07"]:'')+"</td>");
    			var td2 = $("<td>"+(list[i]["bjw02"]?list[i]["bjw02"]:'')+"</td>");
    			var td3 = $("<td>"+(list[i]["iai03"]?list[i]["iai03"]:'')+"</td>");
    			var tr = $("<tr></tr>");
    			tr.append(td1);
    			tr.append(td2);
    			tr.append(td3);
    			target.append(tr);
    		}
    	});
    }
    
    //加载手术人员安排
    function shouShuRenYuanAnpai(vaf01)
    {
    	var url = rootUrl + "/doctoradvice/queryoperationscheduled";;
    	var params= {};
    	params.VAF01 = vaf01;
    	$.post(url,params,function(data){
    		var list = data.list;
    		$("#shoushurenyuananpai_table tbody").empty();
    		for(var i= 0;i<list.length;i++)
    		{
    			var td1 = $("<td>"+list[i]["ace02"]+"</td>");
    			var td2 = $("<td>"+list[i]["bce02"]+"</td>");
    			var td3 = $("<td>"+list[i]["bce03"]+"</td>");
    			var tr = $("<tr></tr>");
    			tr.append(td1);
    			tr.append(td2);
    			tr.append(td3);
    			$("#shoushurenyuananpai_table").append(tr);
    		}
    	});
    }
    
    //医嘱发送记录(草药和手术)
    function vaf1Fasongjilu3(vaf01)
    {
    	var url = rootUrl + "/sendadvicehistory/herbandoperationsendhistory";;
    	var params= {};
    	params.lVAFID = vaf01;
    	$.post(url,params,function(data){
    		var list = data.list;
    		$("#vaf1Fasongjilu_table").empty();
    		for(var i= 0;i<list.length;i++)
    		{
    			var td1 = $("<td>"+(list[i]["fvbi15"]?list[i]["fvbi15"]:'未结账')+"</td>");
    			var td2 = $("<td>"+(list[i]["vbi09"]?list[i]["vbi09"]:'')+"</td>");
    			var td3 = $("<td>"+(list[i]["nbby05"]?list[i]["nbby05"]:'')+"</td>");
    			var td5 = $("<td>"+(list[i]["vbi07"]?list[i]["vbi07"]:'')+"</td>");
    			var td6 = $("<td>"+(list[i]["bck03"]?list[i]["bck03"]:'')+"</td>");
    			var td7 = $("<td>"+(list[i]["bce03a"]?list[i]["bce03a"]:'')+"</td>");
    			var td8 = $("<td>"+(list[i]["fvbi13"]?list[i]["fvbi13"]:'')+"</td>");
    			var td9 = $("<td>"+(list[i]["vbi05"]?list[i]["vbi05"]:'')+"</td>");
    			var tr = $("<tr></tr>");
    			tr.append(td1);
    			tr.append(td2);
    			tr.append(td3);
    			tr.append(td5);
    			tr.append(td6);
    			tr.append(td7);
    			tr.append(td8);
    			tr.append(td9);
    			$("#vaf1Fasongjilu_table").append(tr);
    		}
    	});
    }
    
    //医嘱发送记录(西药)
    function vaf1Fasongjilu1(vaf01)
    {
    	var url = rootUrl + "/sendadvicehistory/sendpharmacyhistory";;
    	var params= {};
    	params.lVAF01 = vaf01;
    	params.lVAF01A = vaf01;
    	$.post(url,params,function(data){
    		var list = data.list;
    		$("#vaf1Fasongjilu_table").empty();
    		for(var i= 0;i<list.length;i++)
    		{
    			var td1 = $("<td>"+(list[i]["fvbi15"]?list[i]["fvbi15"]:'')+"</td>");
    			var td2 = $("<td>"+(list[i]["vbi09"]?list[i]["vbi09"]:'')+"</td>");
    			var td3 = $("<td>"+(list[i]["nbby05"]?list[i]["nbby05"]:'')+"</td>");
    			var td5 = $("<td>"+(list[i]["vbi07"]?list[i]["vbi07"]:'')+"</td>");
    			var td6 = $("<td>"+(list[i]["bck03"]?list[i]["bck03"]:'')+"</td>");
    			var td7 = $("<td>"+(list[i]["bce03a"]?list[i]["bce03a"]:'')+"</td>");
    			var td8 = $("<td>"+(list[i]["fvbi13"]?list[i]["fvbi13"]:'')+"</td>");
    			var td9 = $("<td>"+(list[i]["vbi01"]?list[i]["vbi01"]:'')+"</td>");
    			var tr = $("<tr></tr>");
    			tr.append(td1);
    			tr.append(td2);
    			tr.append(td3);
    			tr.append(td5);
    			tr.append(td6);
    			tr.append(td7);
    			tr.append(td8);
    			tr.append(td9);
    			$("#vaf1Fasongjilu_table").append(tr);
    		}
    	});
    }
    
    
    //医嘱发送记录(其它)
    function vaf1FasongjiluOther(vaf01)
    {
    	var url = rootUrl + "/sendadvicehistory/otheradvicesendhistory";
    	var params= {};
    	params.VAF01 = vaf01;
    	$.post(url,params,function(data){
    		var list = data.list;
    		$("#vaf1Fasongjilu_table").empty();
    		for(var i= 0;i<list.length;i++)
    		{
    			var td1 = $("<td>"+(list[i]["fvbi15"]?list[i]["fvbi15"]:'')+"</td>");
    			var td2 = $("<td>"+(list[i]["vbi09"]?list[i]["vbi09"]:'')+"</td>");
    			var td3 = $("<td>"+(list[i]["nbby05"]?list[i]["nbby05"]:'')+"</td>");
    			var td5 = $("<td>"+(list[i]["vbi07"]?list[i]["vbi07"]:'')+"</td>");
    			var td6 = $("<td>"+(list[i]["bck03"]?list[i]["bck03"]:'')+"</td>");
    			var td7 = $("<td>"+(list[i]["bce03a"]?list[i]["bce03a"]:'')+"</td>");
    			var td8 = $("<td>"+(list[i]["fvbi13"]?list[i]["fvbi13"]:'')+"</td>");
    			var td9 = $("<td>"+(list[i]["vbi05"]?list[i]["vbi05"]:'')+"</td>");
    			var tr = $("<tr></tr>");
    			tr.append(td1);
    			tr.append(td2);
    			tr.append(td3);
    			tr.append(td5);
    			tr.append(td6);
    			tr.append(td7);
    			tr.append(td8);
    			tr.append(td9);
    			$("#vaf1Fasongjilu_table").append(tr);
    		}
    	});
    }
    
    
    
    //根据医嘱状态查询医嘱（前端实现）
    function checkboxEvent1()
	{
    	$('#vaf10_1').on('ifChecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('新开')").parents("tbody").show(); 
  		});
    	$('#vaf10_1').on('ifUnchecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('新开')").parents("tbody").hide();
  		});
		
	}
  //发送
    function checkboxEvent8()
    {
    	$('#vaf10_8').on('ifChecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('已发送')").parents("tbody").show(); 
  		});
    	$('#vaf10_8').on('ifUnchecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('已发送')").parents("tbody").hide();  
  		});
    	
    }
    
    function checkboxEvent4()
    {
    	//作废
    	$('#vaf10_4').on('ifChecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('医嘱退费')").parents("tbody").show();  
  		});
    	$('#vaf10_4').on('ifUnchecked', function(event){
    		$("#advice_table tbody tr").find("td:eq(2)").filter(":contains('医嘱退费')").parents("tbody").hide();  
  		});
    }
   //医嘱记录操作切换
    function yizhuOperation(){
    	$(".patient_operation .listMenu").on("click",function() {
    				var listNum
    				$(this).addClass("listDownLine").siblings().removeClass("listDownLine");
    				var listNum = $(this).index();
    				$(".yizhujilu_content .yizhu_content").eq(listNum).removeClass("hidden").siblings().addClass("hidden");
    			});
    }

    
    //医嘱直接打印
    function print()
    {
    	debugger;
    	$(".iswest").show();
    	$(".print_btn").attr("disabled",true);

    	if ($(".innerHead td input:checked").length <= 0)
    	{
    		layer.msg("请勾选要打印的医嘱单",
    		{
    		time : 2000,
    		icon : 0,
    		skin: 'layui-layer-msg0'
    		});
    		$(".print_btn").removeAttr("disabled");
    		return;
    	}
    	else if($(".innerHead td input:checked").length > 1)
    	{
    		layer.msg("只能勾选一个已发送的医嘱单",
    				{
    				time : 2000,
    				icon : 0,
    				skin: 'layui-layer-msg0'
    				});
    		$(".print_btn").removeAttr("disabled");
    				return;
    	}
    	else
    	{
    			var dataStr=$($(".innerHead td input:checked").parents("tbody").find(".yizhu_details")[0]).attr("data-info");
    			var dataObj = JSON.parse(dataStr);
    			cbm01 = dataObj.cbm01;
    			var bda01 = dataObj.bda01;
    			var vaf10 = dataObj.vaf10;
    			if(vaf10!=8)
    			{
    				layer.msg("请先发送医嘱单",
    						{
    						time : 2000,
    						icon : 0,
    	    				skin: 'layui-layer-msg0'
    						});
    				$(".print_btn").removeAttr("disabled");
    						return;
    			}
    			var rid;
    			switch (bda01)
    			{
    				case "1" :
    					rid = justXiyaoType(dataObj.cbm07,rid);
    					break;
    				case "2" :
    					rid = justXiyaoType(dataObj.cbm07,rid);
    					break;
    				case "8" :
    					rid = 25;
    					break;
    				case "E" :
    					rid = 22;
    					break;
    				case "L" :
    					rid = 23;
    					break;
    				case "S" :
    					rid = 28;
    					break;
    				case "4" :
    					rid = 999;//待定
    					break;
    				case "M" :
    					rid = 999;//待定
    					break;
    				default ://治疗
    					rid = 190;
    					break;
    			}
    				var myAjax = $.ajax({
    					url : printUrl + "/printtemprest/findListByRid/" + rid+"?jsessionids="+$.cookie('jsessionids'),
    					type : "get",
    					async : true,
    					dataType : "json",
    					traditional : true,
    					success : function(data) {
    						$(".print_btn").removeAttr("disabled");
    						var html ="";
    						for (var i = 0; i < data.length; i++) {
    							var obj = {};
    							obj.vaf10 = vaf10;
    							obj.id = data[i]['id'];
    							if (data[i]['xdefault'] == "1") {
    								html += '<option data-info='+JSON.stringify(obj)+'>'+data[i]['name']+'</option>';
    							} else {
    								html += '<option data-info='+JSON.stringify(obj)+'>'+data[i]['name']+'</option>';
    							}
    						}
    						$("#advice_print").empty().append(html);
    						print_content();
    					},
    					error : function(XMLHttpRequest, textStatus, errorThrown) {
    						layer.msg('打印服务器连接失败！', {
    							time : 2000,
    							icon : 3,
    							skin: 'layui-layer-msg3'
    						});
    						$(".print_btn").removeAttr("disabled");
    					}
    				});
    			
    		}
    }

function closeAndPrint(sobj)
{
	debugger;
	var lvac01 = sobj.vac01,flag = sobj.flag,list = sobj.list,msg = sobj.msg
	layer.closeAll();
	printIm(flag,list);
	reloadPatientInfo(lvac01);
	var vipId = $("#vipId").text();
	if (valueArr['p_100_105002_362']=='1' && vipId != "--" &&msg)
	{
		var indexl = layer.alert(msg,
		{
		icon : 1,
		title : "温馨提示：",
		yes:function(){
			isInfectionsDisease(sobj.sql); //传染病报告卡
			layer.close(indexl);
		}
		});
	}else{
		isInfectionsDisease(sobj.sql); //传染病报告卡
	}
	
}
function orderInIndex(){
	var now =  new Date($.ajax({async: false}).getResponseHeader("Date"));
	var dd = now.Format('yyyy-MM-dd hh:mm:ss:S');//时间到时分秒毫秒
	var page = $(document).find("#neworder_layer iframe").contents().find("#shuxiebingli");
	var page_body = $(document).find("#neworder_layer iframe").contents().find("body");
	if($(page).attr("src")){
	    var layId = "emr"
		exec_obj = document.createElement('iframe');
		exec_obj.name = 'tmp_frame';
		exec_obj.src = dzbl+'/out_interface_doctor1.jsp?layId='+ layId+'&lastDate='+dd;
		exec_obj.style.display = 'none';
		page_body.append(exec_obj);
	}
	layer.closeAll()
}